{include file='public/meta'}
<title>管理员列表</title>
</head>
<body>
{include file='public/header'}
{include file='public/menu'}
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
		<span class="c-gray en">&gt;</span>
		{$controller}
		<span class="c-gray en">&gt;</span>
		{$action}
		<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
	</nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="text-c">
				<form action="{:url('admin/member/member_list')}" method="post">
				<span class="select-box inline">
				<select name="cond" class="select">
					<option value="all">全部分类</option>
					<option value="uname">姓名</option>
					<option value="area">区域</option>
					<option value="gid">职位</option>
				</select>
				</span>
				<input type="text" name="key" id="" placeholder=" 关键字" style="width:250px" class="input-text">
				<button name="" id="" class="btn btn-success radius" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜管理员</button>
				</form>
			</div>
			<div class="cl pd-5 bg-1 bk-gray mt-20">
				<span class="l">
					<a href="javascript:;" onclick="batchdel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a>
					<a id="member_add" class="btn btn-primary radius" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a>
				</span>
				<span class="r">共有数据：<strong>{$data|count}</strong> 条</span>
			</div>
			<div class="mt-20">
				<table class="table table-border table-bordered table-bg table-hover table-sort">
					<thead>
						<tr class="text-c">
							<th><input name="" type="checkbox" value=""></th>
							<th>ID</th>
							<th>头像</th>
							<th>姓名</th>
							<th>联系方式</th>
							<th>区域</th>
							<th>加入时间</th>
							<th>职位</th>
							<th>操作</th>
						</tr>
					</thead>
					<tbody>
						{volist name="data" id="vo"}
						<tr class="text-c va-m">
							<td><input class="ck" name="" type="checkbox" value="{$vo.uid}"></td>
							<td>{$vo.uid}</td>
							<td><a class="m_info" href="javascript:;"><span style="display:none;">{$vo.uid}</span><img width="60" class="product-thumb" src="/static/upload/member/{$vo.thumb}"></a></td>
							<td>{$vo.uname}</td>
							<td>{$vo.utel}</td>
							<td>{$vo.area}</td>
							<td>{$vo.utime}</td>
							{if condition="$vo.gid=='业务员'"}
							<td class="td-gid"><span class="label label-info radius">{$vo.gid}</span></td>
							{elseif condition="$vo.gid=='区域经理'"}
							<td class="td-gid"><span class="label label-primary radius">{$vo.gid}</span></td>
							{elseif condition="$vo.gid=='超级管理员'"}
							<td class="td-gid"><span class="label label-success radius">{$vo.gid}</span></td>
							{elseif condition="$vo.gid=='维修员'"}
							<td class="td-gid"><span class="label label-warning radius">{$vo.gid}</span></td>
							{elseif condition="$vo.gid=='保洁员'"}
							<td class="td-gid"><span class="label label-danger radius">{$vo.gid}</span></td>
							{else}
							<td class="td-gid"><span class="label label-default radius">{$vo.gid}</span></td>
							{/if}
							<td class="td-manage">
								<a style="text-decoration:none" class="ml-5" onClick="member_edit(this,{$vo.uid})" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>
								<a style="text-decoration:none" class="ml-5" onClick="member_del(this,{$vo.uid})" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
							</td>
						</tr>
						{/volist}
					</tbody>
				</table>
			</div>
		</article>
	</div>
</section>

{include file='public/footer'}
<!--请在下方写此页面业务相关的脚本-->
{load href='/static/lib/My97DatePicker/4.8/WdatePicker.js'}
{load href='/static/lib/datatables/1.10.0/jquery.dataTables.min.js'}
{load href='/static/lib/laypage/1.2/laypage.js'}

<script type="text/javascript">
	$('#member_add').click(function(){
		// layer_show('添加管理员','{:url('admin/member/member_add')}','550','500');
		layer.open({
			type: 2,
			area: ['550px', '500px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: '添加管理员',
			content: '{:url('admin/member/member_add')}',
			end:function(){
				location.href = '{:url('admin/member/member_list')}';
			}
		});
	})
	
	//批量删除
	function batchdel(){
		var re = '';
		$('input[type=checkbox]:checked').each(function(){
			re += $(this).val()+',';
		})
		var data = 'uid='+re;
		$.post('{:url('admin/member/do_del')}',data,function(res){
			console.log(res);
		})
		$('input[type=checkbox]:checked').parents("tr").remove();
		if(re == ''){
			layer.msg('未选中任何记录!',{icon:1,time:1000});
		}else{
			location.reload();
			layer.msg('批量删除成功!',{icon:1,time:1000});
		}
	}

	//单个删除
	function member_del(obj,id){
		layer.confirm('确认要删除吗？',{icon:3,title:'提示'},function(index){
			var data = 'uid='+id;
			$.post('{:url('admin/member/do_del')}',data,function(res){
				console.log(res);
			})
			$(obj).parents("tr").remove();
			layer.msg('已删除!',{icon:1,time:1000});
		});
	}

	//单个编辑
	function member_edit(obj,id){
		// layer_show('编辑管理员','{:url('admin/member/member_edit')}'+'?uid='+id,'550','500');
		layer.open({
			type: 2,
			area: ['550px', '500px'],
			fix: false, //不固定
			maxmin: true,
			shade:0.4,
			title: '编辑管理员',
			content: '{:url('admin/member/member_edit')}'+'?uid='+id,
			end:function(){
				location.href = '{:url('admin/member/member_list')}';
			}
		});
	}

	//点击头像查看简介
	$('.m_info').click(function(){
		var id = $(this).children('span').text();
		layer_show('个人简信','{:url('admin/member/m_info')}'+'?uid='+id,'350','240');
	});

	$('.table-sort').dataTable({
		"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  {"orderable":false,"aTargets":[0,7]}// 制定列不参与排序
		]
	});
</script>
</body>
</html>	